package be.gnx.fogo.application.util;

public class StringUtil {

  public static String normalizeName(String value) {
    return normalizeString(value, "Unknown");
  }

  public static String normalizeString(String value, String defaultValue) {
    if (value == null) {
      value = defaultValue;
    }
    if (value == null) {
      return value;
    }
    value = value.trim();
    if (value.length() == 0) {
      value = defaultValue;
    }
    if (value == null) {
      return value;
    }
    if (value.charAt(0) == '"') {
      value = value.substring(1, value.length());
    }
    if (value.charAt(value.length() - 1) == '"') {
      value = value.substring(0, value.length() - 1);
    }
    value = value.trim();
    if (value.length() == 0) {
      value = defaultValue;
    }
    return value;
  }

}
